// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license


#pragma once

#include "Node.h"
#include "Transformable.h"

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Class "TransformNode"
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// A subclass of Node that:
// * Has a custom local transform and some helper methods to modify it.
// ----------------------------------------------------------------------------
// This class can be directly instantiated and added to the scene tree, or it 
// can be subclassed into a new node type. So there are two ways to obtain
// a "transformable" node. 1) Making it a subclass of TransformNode 2) Making
// it a child of a transform node. The first option is less cumbersome and
// should be preferred
// ----------------------------------------------------------------------------

class TransformNode : public Node, public Transformable
{
public:

    // Use the second parameter to provide a more accurate notification (e.g,
    // pass "NodeOrientation" if you're sure that the transformation matrix
    // passed in the first parameter is a pure rotation matrix. If you're
    // not sure or if you're transformation matrix is fully general, use the
    // other overload
    void setLocalTransform(const gx::Mat4 & m, NodeEvent::Property prop);

    // Transformable overrides
    void setLocalTransform(const gx::Mat4 & m) override;
    
    gx::Mat4 getGlobalTransform() const { return Node::getGlobalTransform(); }

    // --------------------------------------------------------------
    // Serialization

    void read(std::wistream& is) override;
    void write(std::wostream& os) const override;
};

